import torch


if __name__ == '__main__':
    checkpoint = torch.load('gpt2_model.pth', map_location='cpu')

    # print(f'checkpoint.keys()-->')
    # for key in checkpoint.keys(): print(key)

    print(f'dype--->: {type(checkpoint)}')

    yes_or_no = isinstance(checkpoint, dict)
    print(f'isinstance(checkpoint, dict)-->: {yes_or_no}')

    yes_or_no = all(isinstance(v, torch.Tensor) for v in checkpoint.values())
    print(f'all(isinstance(v, torch.Tensor) for v in checkpoint.values())-->: {yes_or_no}')

# 打印结果:
# dype--->: <class 'collections.OrderedDict'>
# isinstance(checkpoint, dict)-->: True
# all(isinstance(v, torch.Tensor) for v in checkpoint.values())-->: True
